<template>
  <div>
    <h2>必须加入key的情况</h2>
    <ul>
      <li v-for="item in list" :key="item.id">
        <input type="checkbox" />
        {{ item.id }}--{{ item.name }}
        <button @click="del(item.id)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { id: 200, name: "宋江" },
        { id: 400, name: "吴用" },
        { id: 528, name: "林冲" },
      ],
    };
  },
  methods:{
    del(id){
      this.list=this.list.filter(item=>item.id !==id);
    }
  }
};
</script>

<style></style>
